package ex2.employee;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CReportHandler implements IReportHandler {

	private IEmployeeHandler _employeeHandler;
	
	CReportHandler (IEmployeeHandler employeeHandler){
		this._employeeHandler = employeeHandler;
		
	}
	
	@Override
	public Collection<IEmployee> getExpenses(double amount) {
		
		Collection<IEmployee> Employees = new ArrayList<IEmployee>();
		IEmployee tEmployee = null;
		
		for(Iterator<IEmployee> iterator = this._employeeHandler.getEmployees().iterator(); iterator.hasNext();){
			
			tEmployee=iterator.next();
			
			if(tEmployee.calaulateTotalExpenses() > amount)
				Employees.add(tEmployee);
		}
				
		return Employees;
		
	}

	@Override
	public Collection<IEmployee> getEquipment(String equipment) {
		
		Collection<IEmployee> SpecialistWhoUse = new ArrayList<IEmployee>();
		IEmployee tIteratorEmployee = null;
		
		for(Iterator<IEmployee> iterator = this._employeeHandler.getEmployees().iterator(); iterator.hasNext();){
			
			tIteratorEmployee=iterator.next();
			
			if(tIteratorEmployee.getEmployeeCode().equals("2") && tIteratorEmployee.getEquipment().equals(equipment))
				SpecialistWhoUse.add( (CSpecialist)tIteratorEmployee );
		}
				
		return SpecialistWhoUse;
	}


}
